package com.walk.zworld.ui.location;


import android.annotation.SuppressLint;
import android.text.TextUtils;

import com.walk.zworld.R;
import com.walk.zworld.api.bean.MenuBean;
import com.walk.zworld.ui.base.BaseReclyViewHolder;
import com.walk.zworld.ui.base.BaseRecyclerAdapter;

import java.util.List;

public class MenuUserAdapter extends BaseRecyclerAdapter<MenuBean,BaseReclyViewHolder> {
    public MenuUserAdapter(List<MenuBean> data) {
        super(R.layout.item_relcy_menu_user, data);
    }

    @SuppressLint("ResourceAsColor")
    @Override
    public void convert(BaseReclyViewHolder helper, MenuBean item) {
        helper.setText(R.id.tv_name,item.getName());
        int id=item.getLocalIcon();
        String url=item.getPic();
        if(id!=-1&&id!=0){
            helper.setImageResouceId(id,R.id.img_icon);
        }else if (!TextUtils.isEmpty(url) && url.startsWith("http")){
            helper.setImageUrl(url,R.id.img_icon);
        }else {
            helper.setImageResouceId(R.drawable.ic_step_blue,R.id.img_icon);
        }
        helper.setTextColor(R.id.tv_name,R.color.color_333);
        helper.findView(R.id.menu_item_layout).setTag(item);
    }

}
